package name.fowler.refactoring.simplestore;

import name.fowler.refactoring.simplestore.domain.Rental;
import name.fowler.refactoring.simplestore.domain.Movie;
import name.fowler.refactoring.simplestore.domain.Customer;
import name.fowler.refactoring.simplestore.domain.pricecode.PriceCodeChildren;
import name.fowler.refactoring.simplestore.domain.pricecode.PriceCodeNewRelease;
import name.fowler.refactoring.simplestore.domain.pricecode.PriceCodeRegular;
import name.fowler.refactoring.simplestore.reports.Formatter;
import name.fowler.refactoring.simplestore.reports.FormatterFactory;
import name.fowler.refactoring.simplestore.reports.PriceReport;
import name.fowler.refactoring.simplestore.reports.Report;

class MainClass {

    public static void main(String[] args) {
    	
        PriceCodeChildren priceCodeChildren = new PriceCodeChildren();
        PriceCodeRegular priceCodeRegular = new PriceCodeRegular();
        PriceCodeNewRelease priceCodeNewRelease = new PriceCodeNewRelease();

        // Create movies
        Movie movCinderella = new Movie("Cinderella", priceCodeChildren);
        Movie movStarWars = new Movie("Star Wars", priceCodeRegular);
        Movie movGladiator = new Movie("Gladiator", priceCodeNewRelease);

        // Create customers
        Customer custMickeyMouse = new Customer("Mickey Mouse");
        Customer custGuffy = new Customer("Guffy");

        // Create rentals
        Rental rental1 = new Rental(5);
        rental1.addMovie(movCinderella);
        rental1.addMovie(movGladiator);
        Rental rental2 = new Rental(3);
        rental2.addMovie(movStarWars);

        // Assign rentals to customers
        custMickeyMouse.addRental(rental1);
        custMickeyMouse.addRental(rental2);
        custGuffy.addRental(rental1);

        // Print report
        Formatter formatter = FormatterFactory.getFormatter(Formatter.Format.HTML);
    	Report report = new PriceReport(custMickeyMouse, custGuffy);
    	System.out.println(report.generate(formatter));
    }
}
